home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / iqb9104.zip / LJDEMO2.BAS < prev    next >
BASIC Source File  |  1991-04-05  |  3KB  |  92 lines

  1. ' LJDEMO2.BAS--A program demonstrating PCL shaded-box graphics
  2. '
  3. DECLARE SUB BoxString (instr$)
  4.  
  5. ' Print an asterisk at (1200,1500) - the exact center of the page
  6.  
  7. LPRINT CHR$(27); "*p1200x1500Y";   ' move to (1200,1500)
  8. LPRINT "* (1200,1500)"             ' display message
  9. LPRINT CHR$(27); "E"               ' eject page
  10.  
  11. ' Print a 2" x 3" shaded box using cross-hatch pattern 4 at (450,450)
  12.  
  13. LPRINT CHR$(27); "*p450x450Y";     ' move cursor at (450,450)
  14.                                    ' set width to 600, and
  15. LPRINT CHR$(27); "*c600a900B";     ' set eight to 900
  16. LPRINT CHR$(27); "*c4G";           ' do cross-hatching pattern 4
  17. LPRINT CHR$(27); "*c3P"            ' print shaded box
  18. LPRINT CHR$(27); "E"               ' eject page
  19.  
  20. ' Print a 8" x 1/4" bar with 56% shading at (0,2925)
  21.  
  22. LPRINT CHR$(27); "*p0x2925Y";      ' move cursor at (0,2925)
  23.                                    ' set width to 2400, and
  24. LPRINT CHR$(27); "*c2400a75B";     ' set eight to 75
  25. LPRINT CHR$(27); "*c56G";          ' select 56% shading pattern
  26. LPRINT CHR$(27); "*c2P"            ' print shaded bar
  27. LPRINT CHR$(27); "E"               ' eject page
  28.  
  29. ' Print a black box within a cross-hatch #2 box
  30. ' First, do the cross-hatch filled box
  31.  
  32. LPRINT CHR$(27); "*p300x300Y";     ' move cursor at (300,300)
  33.                                    ' set height to 1200, and
  34. LPRINT CHR$(27); "*c1200a1200B";   ' set hwidth to 1200
  35. LPRINT CHR$(27); "*c2G";           ' set cross-hatch pattern 2
  36. LPRINT CHR$(27); "*c3P"            ' print shaded box
  37.  
  38. ' Now, do the black box
  39.  
  40. LPRINT CHR$(27); "*p600x600Y";     ' move cursor at (600,600)
  41.                                    ' set height to 600, and
  42. LPRINT CHR$(27); "*c600a600B";     ' set width to 600
  43.                                    ' no pattern for black
  44. LPRINT CHR$(27); "*c0P"            ' print black box
  45.  
  46. LPRINT CHR$(27); "E"               ' eject page
  47.  
  48. ' Lastly, get a line of text from the user, and print it
  49. ' centered in a white box centered inside a 21% shaded box
  50.  
  51. LINE INPUT "Please enter a line of text >", HeadLine$
  52. BoxString HeadLine$
  53.  
  54. END
  55.  
  56. SUB BoxString (Instr$) STATIC
  57.  
  58. ' A general-purpose subprogram to box and center a string
  59. ' at the top of a page.  Requires a LaserJet III printer.
  60.  
  61.   Border% = 75           ' all borders are 1/4" (75 dots)
  62.   CenterOfPage% = 1200   ' center of 8.5" page w/ 1/4" margins
  63.   StrWidth% = LEN(Instr$) * 30   ' default font is 30 dots wide
  64.  
  65. ' calculate dimensions and starting point for shaded box
  66.   ShadeX% = CenterOfPage% - (Border% * 2) - (StrWidth% / 2)
  67.   ShadeY% = 0
  68.   ShadeWidth% = (Border% * 4) + StrWidth%
  69.   ShadeHeight% = (Border% * 2) + 75
  70.  
  71. ' send escape sequences for shaded box
  72.   LPRINT CHR$(27); "*p"; ShadeX%; "x"; ShadeY%; "Y";
  73.   LPRINT CHR$(27); "*c"; ShadeWidth%; "a"; ShadeHeight%; "B";
  74.   LPRINT CHR$(27); "*c21g2P"
  75.  
  76. ' calculate dimensions for white box inside shaded box
  77.   WhiteX% = ShadeX% + Border%
  78.   WhiteY% = Border%
  79.   WhiteWidth% = (Border% * 2) + StrWidth%
  80.   WhiteHeight% = 75
  81.  
  82. ' send escape sequences for white box
  83.   LPRINT CHR$(27); "*p"; WhiteX%; "x"; WhiteY%; "Y";
  84.   LPRINT CHR$(27); "*c"; WhiteWidth%; "a"; WhiteHeight%; "B";
  85.   LPRINT CHR$(27); "*c1P"
  86.  
  87. ' center and print string, then eject page
  88.   LPRINT SPACE$(40 - LEN(Instr$) / 2); Instr$
  89.   LPRINT CHR$(27); "E"
  90.  
  91. END SUB
  92.